package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.SystemMessage;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.SystemMessageQueryObject;
import cn.wolfcode.trip.base.service.ISystemMessageService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("systemMessage")
public class SystemMessageController {
    @Autowired
    private ISystemMessageService systemMessageService;
    @RequestMapping("list")
    public String list(@ModelAttribute("qo") SystemMessageQueryObject qo,Model model){
        qo.setOrderBy("createTime desc");
        PageInfo pageInfo = systemMessageService.query(qo);
        model.addAttribute("pageInfo",pageInfo);
        return "/message/systemMessage";
    }

    @RequestMapping("save")
    @ResponseBody
    public JsonResult save(SystemMessage systemMessage) {
        systemMessageService.save(systemMessage);
        return new JsonResult();
    }

}
